package com.frxuexi.park2209.adapter

import android.view.View
import android.widget.CheckBox
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.base.entity.RepairBeanItem
import com.frxuexi.base.mvvm.BaseViewModel
import com.frxuexi.park2209.R

class RepairAdapter : BaseQuickAdapter<RepairBeanItem, BaseViewHolder>(R.layout.item_repair) {
    override fun convert(helper: BaseViewHolder, item: RepairBeanItem) {
        helper.setText(R.id.rep_title, item.repairData)
        helper.setText(R.id.rep_content, item.repairDescribe)
        helper.setText(R.id.rep_uid, "${item.userId}")
        val tv = helper.getView<TextView>(R.id.btn_approve)
        val approve = if (item.repairUserId == 0) {
            tv.setBackgroundResource(R.drawable.shape_noapprove)
            "未审核"
        } else {
            tv.setBackgroundResource(R.drawable.shape_approve)
            "已审核"
        }

        val cb = helper.getView<CheckBox>(R.id.cb)
        if(item.isShow){
            cb.visibility=View.VISIBLE
        }else{
            cb.visibility=View.GONE
        }

        cb.isChecked=item.isChecked


        helper.setText(R.id.btn_approve, approve)
    }
}